
/*
 * @Description: 界面报错统一处理
 * @Project: 
 * @Author: michelle
 * @Date: 2022-02-23 14:15:41
 * @LastEditors: michelle
 * @LastEditTime: 2022-02-23 14:22:32
 * @Modified By: michelle
 * @FilePath: /vite-project/src/components/exception/index.jsx
 */
import React from 'react'
import './index.less'
import { Result, Button } from 'antd'
import { useNavigate } from 'react-router-dom'

const statusMap = {
    403: {
        title: '403',
        subTitle: 'Sorry, you are not authorized to access this page.',
    },
    404: {
        title: '404',
        subTitle: 'Sorry, the page you visited does not exist.',
    },
    500: {
        title: '500',
        subTitle: 'Sorry, the server is wrong.',
    }
}

const NoMatch = function ({
    status = '404'
}) {
    const navigate = useNavigate()

    function goBack() {
        navigate(-1)
    }

    return (
        <Result
            status={status}
            extra={<Button type="primary" onClick={goBack}>Back</Button>}
            {...statusMap[status]}
        />
    )
}

export default NoMatch
